#include "colorform.h"
#include "ui_colorform.h"

colorForm::colorForm(QString strColor, QString strTxt, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::colorForm)
{
    ui->setupUi(this);
    ui->label_context->setText(strTxt);
    ui->label_context->adjustSize();// // 根据文本内容调整大小
    QColor col(strColor);
    QPalette palette = ui->label_color->palette();
    palette.setColor(QPalette::Window, col); // 设置背景颜色
    ui->label_color->setPalette(palette);
    // 设置QLabel自动填充背景
    ui->label_color->setAutoFillBackground(true);
}

colorForm::~colorForm()
{
    delete ui;
}

void colorForm::paintEvent(QPaintEvent *event)
{
    QWidget::paintEvent(event);
    this->adjustSize();
}
